package ArrayList;

import java.util.ArrayList;

public class test4 {
    public static void main(String[] args) {
//        arrayListForEach();
//        arrayListForEach4();
        ArrayObject();
    }

    private static void ArrayObject() {
        Student student1 = new Student("tkf",18);
        Student student2 = new Student("tkf2",19);
        ArrayList<Student> arr =  new ArrayList<>();
        arr.add(student1);
        arr.add(student2);
        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arr.get(i));
        }
    }

    private static void arrayListForEach4() {
        ArrayList<String> arr  = new ArrayList<>();
        arr.add("肛门吹雪");
        arr.add("西域狂鸭");
        arr.add("3");
        arr.add("久旱逢甘霖");
        for (int i = 0; i < arr.size(); i++) {
            String s = arr.get(i);
            if(s.length() == 4)
            System.out.println(s);
        }
    }
    private static void arrayListForEach() {
        ArrayList<String> arr  = new ArrayList<>();
        arr.add("1");
        arr.add("2");
        arr.add("3");
        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arr.get(i));
        }
    }
}
